<?php
require '../conn.php';
require 'config.php';
require '../inc/function.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/admin.css" type="text/css" />
<script type="text/javascript" src="inc/function.js"></script>
</head>
<body>
<?php
switch($act){
case 'delete':
	$image_original=RsField_Array('select s_image from '.$language.'_security where s_id='.$id);
	mysql_query('delete from '.$language.'_security where s_id='.$id);
	DeleteFile('../'.$image_original[0]);
	Msg('','Referer');
	break;
case 'deletes':
	if (count($_POST['checkbox'])>0){
		$id_arr=implode(',',$_POST['checkbox']);
		$query=mysql_query("select s_id,s_image from ".$language."_security where s_id in ($id_arr)");
		if (mysql_num_rows($query)>0){
		while($row=mysql_fetch_array($query)){
			mysql_query('delete from '.$language.'_security where s_id='.$row['s_id']);
			DeleteFile('../'.$row['s_image']);
		}
		}
	}
	Msg('删除数据成功！','Referer');
	break;
}
?>
<div id="container">
	<input type="text" id="search_key" class="search_input" size="30" value="<?php echo  $search_key ?>" />
	<input type="button" name="button" class="search_button" value="搜 索" onclick="location.href='?search_key='+$('search_key').value" />
	<div class="view" style="margin-top:5px;">
		<h1>防伪码管理<a href="javascript:location.reload();">刷新</a></h1>
		<form name="form1" id="form1" method="post" action="?act=deletes&<?php echo $urls ?>">
	    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        	<tr class="v_title">
            	<td width="8%">ID号</td>
				<td width="12%">图片预览</td>
				<td width="18%">防伪码</td>
				<td width="22%">产品名称</td>
				<td width="14%">出口国</td>
				<td width="14%">进口国</td>
				<td width="12%">操作</td>
        	</tr>
			<?php
			$str='';
			$page_size=10;
			if ($search_key!='') $sqls=" and (s_name like '%{$search_key}%' or s_code='{$search_key}')";
			$page_sql='select * from '.$language.'_security where 1=1'.$sqls.' order by s_id desc';
			$page_count=GetPageCount($page_size,$page_sql);
			if ($page>$page_count) $page=$page_count;
			$page_number=($page-1)*$page_size;
			$query=mysql_query($page_sql." limit $page_number,$page_size",$conn);
			if (mysql_num_rows($query)>0){
			while($row=mysql_fetch_array($query)){
				$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';
				$str.='<td><input type="checkbox" name="checkbox[]" value="'.$row['s_id'].'" align="absmiddle" />&nbsp;'.$row['s_id'].'</td>';
				$str.='<td style="padding:5px; line-height:normal; font-size:0px;"><a href="../'.$row['s_image'].'" target="_blank"><img src="../'.$row['s_image'].'" height="40" /></a></td>';
				$str.='<td>'.$row['s_code'].'</td>';
				$str.='<td>'.$row['s_name'].'</td>';
				$str.='<td>'.$row['s_m1'].'</td>';
				$str.='<td>'.$row['s_m2'].'</td>';
				$str.='<td><a href="security_modify.php?'.$urls.'&id='.$row['s_id'].'">修改</a> | <a href="?act=delete&id='.$row['s_id'].'" onclick="return ConfirmDel();">删除</a></td>';
				$str.='</tr>';
			}
			}
			else {
				$page_show=false;
			}
			echo $str;
			?>
		</table>
		</form>
		<?php if($page_show) echo ShowPage($page,$page_size,$page_sql); ?>
	</div>
</div>
</body>
</html>